package gwtappcontainer.shared.apps.insight;


import java.util.ArrayList;

public class Member implements Comparable<Member> {
	
	public static class ContactDetails {		
		public String email;
		public String phone;	
		public String firstName;
		public String middleName;
		public String lastName;	
		public String homeAddress;
		public String homePhone;	
		public String officeAddress;
		public String officePhone;	
		public String singaporeNRIC;
	}
		
	public int id;
	public ContactDetails contactDetails = new ContactDetails();
	public Center owningCenter = new Center();	
	public ArrayList<Center> additionalCenters = new ArrayList<>();			
	public ArrayList<UnlistedProgram> unlistedPrograms = new ArrayList<>();	
	public ArrayList<ProgramTypeProp> programTypes = new ArrayList<>();

	@Override
	public int compareTo(Member arg0) {
		//if both first names are there, sort by first name
		if ((this.contactDetails.firstName != null) && (arg0.contactDetails.firstName != null))
			return this.contactDetails.firstName.toUpperCase()
					.compareTo(this.contactDetails.firstName.toUpperCase());		
		else if ((this.contactDetails.firstName != null) && (arg0.contactDetails.firstName == null))
			return 1;		
		else if ((this.contactDetails.firstName == null) && (arg0.contactDetails.firstName != null))
			return -1;		
		else 
			//sort by email when both first names are not specified
			return this.contactDetails.email.compareTo(this.contactDetails.email);				
	}	
}